package com.lg.meng.widgets;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.viewpager.widget.ViewPager;

public class NoScrollViewPager extends ViewPager {

    private boolean canScroll;

    public NoScrollViewPager(Context context) {
        this(context, null);
    }

    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        return this.canScroll ? super.onInterceptTouchEvent(motionEvent) : false;
    }

    public boolean onTouchEvent(MotionEvent motionEvent) {
        if (this.canScroll) {
            super.onTouchEvent(motionEvent);
        }
        return false;
    }

    public void setCanScroll(boolean z) {
        this.canScroll = z;
    }

    public NoScrollViewPager(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.canScroll = false;
    }
}